package demo01;

import java.util.Scanner;

/*题目：给一个不多于5位的正整数，要求：一、求它是几位数，二、逆序打印出各位数字。*/
public class topic24 {
    public static void main(String[] args) {
        System.out.println("请输入不大于5位的正整数：");
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int x= 0;
        while(num>100000 || num<0) {	//判断是否大于5位数或是否是正整数
            System.out.println("输入错误！");
            System.out.println("请输入不大于5位的正整数：");
            num = sc.nextInt();
        }
        String len = String.valueOf(num);
        System.out.println("它是"+len.length()+"位数");
        while(num > 0) {
            x= x*10+num%10;
            num = num/10;
        }
        System.out.println("逆序输出："+x);
    }
}
